//
//  HYNavigationController.m
//  HaiYue
//
//  Created by skyline on 2017/12/15.
//  Copyright © 2017年 skyline. All rights reserved.
//

#import "HYNavigationController.h"

@interface HYNavigationController ()

@end

@implementation HYNavigationController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupNaviBarGroundColor];
    [self setupStatusBarBackgroundColor];
    // Do any additional setup after loading the view.
}

//设置状态栏颜色
- (void)setupStatusBarBackgroundColor
{
    //状态栏字体颜色
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    
    UIView *statusBar;
    if (@available(iOS 13.0,*))
    {
        // iOS 13 弃用keyWindow属性 从所有windowl数组中取
        UIWindow *keyWindow = [UIApplication sharedApplication].windows[0];
        statusBar = [[UIView alloc] initWithFrame:keyWindow.windowScene.statusBarManager.statusBarFrame];
        [keyWindow addSubview:statusBar];
    }
    else
    {
        statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    }
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)])
        statusBar.backgroundColor = THEME_COLOR;
    
}
- (void)setupNaviBarGroundColor
{
    //设置导航栏字体颜色
    self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    //设置导航栏左右按钮字体颜色
    self.navigationBar.tintColor = [UIColor whiteColor];
    //设置导航栏背景颜色
    self.navigationBar.translucent = NO;//加上这一句(否则导航栏有半透明色)
    //去掉navigationBar下划线
    [self.navigationBar setShadowImage:[UIImage new]];
    self.navigationBar.barTintColor = THEME_COLOR;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    viewController.hidesBottomBarWhenPushed = YES;
    [super pushViewController:viewController animated:animated];
    
    NSString *classString = NSStringFromClass([self.topViewController class]);
    NSArray *VC = @[@"HYGameViewController", @"HYSearchViewController", @"HYServerViewController", @"HYTradeViewController",@"HYMyAssetsViewController"];
    if ([VC containsObject:classString]){
        viewController.hidesBottomBarWhenPushed = NO;
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
